import { Controller, Get, Post, Body, Query,Put, Param,Delete } from "@nestjs/common";
import { ApiTags, ApiOperation,ApiProperty } from "@nestjs/swagger";
// /Users/y213140/Documents/LLH/lele_monkey_platform/Mini_wehcat/private.wx56b2b613c5b27145.key
const ci = require('miniprogram-ci');
(async () => {
  const project = new ci.Project({
    appid: 'wx56b2b613c5b27145',
    type: 'miniProgram',
    projectPath: '/Users/y213140/Documents/LLH/lele_monkey_platform/Mini_wehcat/dist',
    privateKeyPath: '/Users/y213140/Documents/LLH/lele_monkey_platform/Mini_wehcat/private.wx56b2b613c5b27145.key',
    ignores: ['node_modules/**/*'],
  });
  console.log(project);
  
  // 自动上传小程序包

  // const uploadResult = await ci.upload({
  //   project,
  //   version: '4.0.0',
  //   desc: 'second_ip_upload',
  //   setting: {
  //     es6: true,
  //   },
  //   onProgressUpdate: console.log,
  // })
  // console.log(uploadResult)
})()

// 创建帖子的数据对象
class CreatePostDto {
    @ApiProperty({description:"帖子标题"})
    titile:string
    @ApiProperty({description:"帖子内容"})
    contect:string
}



@Controller("posts")
@ApiTags("帖子")
export class PostsController {
  @Get()
  @ApiOperation({ summary: "获取博客列表" })
  index(): Array<object> {
    return [];
  }
  @Post()
  @ApiOperation({ summary: "创建帖子" })
  create(@Body() body:CreatePostDto, @Query() query) {
    body;
    // 创建
    return body
  }
  @Get(":id")
  @ApiOperation({summary:"根据id获取帖子详情"})
  detail(@Param("id") id:Number) {
    return {
      id: ci
    };
  }

  @Put(":id")
  @ApiOperation({summary:"编辑帖子"})
  update(@Param("id") id:Number,@Body() body:CreatePostDto){
      return {
          id:id,
          success:true
      }
  }

  @Delete(":id")
  @ApiOperation({summary:"删除某个帖子"})
  delById(@Param("id") id:Number){
      return {
          success:true
      }
  }
}
